﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace Kindle.Base
{
    public static class Base
    {
        /// <summary>
        /// Launch the legacy application with some options set.
        /// </summary>
        public static void LaunchCommandLineApp(string path)
        {
            // For the example
            // Use ProcessStartInfo class
            var startInfo = new ProcessStartInfo();
            startInfo.CreateNoWindow = false;
            startInfo.UseShellExecute = false;
            startInfo.FileName = HttpContext.Current.Server.MapPath("kindlegen.exe");
            startInfo.WindowStyle = ProcessWindowStyle.Hidden;
            startInfo.Arguments = "\"" + HttpContext.Current.Server.MapPath(path) + "\\" + path + ".html\"" + " -o " + path + ".mobi";

            try
            {
                // Start the process with the info we specified.
                // Call WaitForExit and then the using statement will close.
                using (var exeProcess = Process.Start(startInfo))
                {
                    exeProcess.WaitForExit();
                }
            }
            catch (Exception ex)
            {
                // Log error.
            }
        }

        public static void SendToEmail()
        {
            
        }
    }
}
